home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 2 / Amiga Tools 2.iso / net / parnet-3.2 / extras / parpc / amigafiles / sources / defs.h next >
C/C++ Source or Header  |  1995-03-09  |  4KB  |  148 lines

  1.  
  2. /*
  3.  *  DEFS.H
  4.  *
  5.  *  ---- NOTE, ONLY IOREQUEST STRUCTURE IS PUBLIC, ALL OTHER STRUCTURES
  6.  *     **WILL** CHANGE WITHOUT NOTICE ----
  7.  */
  8.  
  9. #define PARNET_SRC
  10.  
  11. #include <proto/all.h>
  12. #include <exec/types.h>
  13. #include <devices/trackdisk.h>
  14. #include <devices/timer.h>
  15. #include <hardware/intbits.h>
  16. #include <exec/errors.h>
  17. #include <exec/interrupts.h>
  18. #include <stdio.h>
  19. #include <stdlib.h>
  20. #include <string.h>
  21.  
  22. #define PORTNAME    "parnet.cfg"
  23.  
  24. #define MAXPKTSIZE  (8192+256)
  25.  
  26. #define IOF_QUEUED  0x02
  27. #define IOF_RUN     0x04
  28.  
  29. #define STRM_RESERVE    0x8000        /*    ports reserved for stream protocol */
  30. #define STRM_PORTS    512        /*    must be factor of 32           */
  31.  
  32. typedef unsigned char    ubyte;
  33. typedef unsigned short    uword;
  34. typedef unsigned long    ulong;
  35.  
  36. typedef struct Library    LIB;
  37. typedef struct MsgPort    PORT;
  38. typedef struct List    LIST;
  39. typedef struct Node    NODE;
  40. typedef struct MinNode    MNODE;
  41. typedef struct Task    Task;
  42. typedef struct Message    Message;
  43.  
  44. typedef struct timerequest IOT;
  45.  
  46. typedef long (*func_ptr)();
  47. typedef void (*func_void)();
  48.  
  49. typedef struct {
  50.     LIB     Lib;        /*    library node        */
  51.     ubyte   ParAddress;     /*    1-255            */
  52.     PORT    Port;        /*    task port        */
  53.     long    PLock[2];        /*    task lock        */
  54.     LIST    UnitList;        /*    active units (ports)    */
  55. } Device;
  56.  
  57. /*
  58.  *  Unit Core Structure (not user accessable) (do not access!)
  59.  */
  60.  
  61. typedef struct {
  62.     NODE    Node;        /*    link node   DO NOT MOVE */
  63.     func_void BeginIO;        /*    begin I/O   DO NOT MOVE */
  64.     func_void AbortIO;        /*    abort I/O   DO NOT MOVE */
  65.     func_void CloseFunc;
  66.     func_void DataFunc;     /*    low level packet data    */
  67.     uword   RefCnt;
  68.     uword   Port;        /*    core port ident     */
  69.     uword   Protocol;        /*    protocol id        */
  70.     ulong   DestAddr;        /*    destination  0 = self    */
  71.     uword   Flags;        /*    status flags        */
  72.     uword   State;        /*    (protocol private)      */
  73.     long    UnitLock[2];
  74.     LIST    PendIOR;        /*    pending read requests        */
  75.     LIST    PendIOW;        /*    pending write requests        */
  76.     LIST    PendCon;        /*    pending connect requests    */
  77.     LIST    PendLsn;        /*    pending listen requests     */
  78. } Unit;
  79.  
  80. /*
  81.  *  Io request structure and user defines
  82.  */
  83.  
  84. #include "devices/parnet.h"
  85.  
  86. typedef IOParReq    Iob;
  87.  
  88. /*
  89.  *  A low level network packet
  90.  */
  91.  
  92. typedef struct {
  93.     Message Msg;
  94.     Iob     *iob;            /*    IO req (unit_str)       */
  95.     Unit    *io_Unit;            /*    unit involved        */
  96.     ubyte   DestAddr;            /*    Destination machine    */
  97.     ubyte   Reserved;
  98.     uword   DestPort;            /*    Destination port no.    */
  99.     ulong   DLen1;            /*    Data Length        */
  100.     ulong   DLen2;            /*    Data Length        */
  101.     ubyte   *Data1;            /*    Data Pointer (lw algn)  */
  102.     ubyte   *Data2;            /*    Data Pointer (lw algn)  */
  103. } Packet;
  104.  
  105. /*
  106.  *  private public port to remember addr across closes.
  107.  */
  108.  
  109. typedef struct {
  110.     PORT    Port;
  111.     long    Address;
  112.     long    Timeout;
  113.     char    DebugBuf[32];
  114. } PubPort;
  115.  
  116. /*
  117.  *  Globals
  118.  */
  119.  
  120. extern long    ParLLTimeout;        /*    par.asm */
  121. extern Device    *DevBase;
  122. extern PubPort    *StickyPort;
  123.  
  124. /* parnet.c */
  125. extern Unit    *FindUnitForPort(uword);
  126. extern Unit    *AllocUnit(Iob *, func_void, func_void, func_void,func_void);
  127. void        FreeUnit(Unit *);
  128. extern Packet    *AllocParPacket(Iob *, Unit *, ubyte *, long, ubyte *, long);
  129. void        FreeParPacket(Packet *);
  130. extern void    ReadConfig(void);
  131. extern void    WriteConfig(void);
  132.  
  133. /* lock.asm */
  134. extern void    LockAddr(long *);
  135. extern void    UnlockAddr(long *);
  136. extern int    TryLockAddr(long *);
  137.  
  138. /* par.asm */
  139. extern void    ParAddress(int);            /*  par.asm    */
  140. extern void    Time10000(void);            /*  par.asm    */
  141.  
  142. /* task.c */
  143. extern void    ParNetTask(void);            /*  task.c    */
  144. void        QueuePacketForWrite(Packet *);
  145.  
  146. /* unit_ctl.c */
  147. void        CtlBeginIO(Iob *);
  148.